package n1028;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args)  throws Exception{

		Stack<String> a=new Stack<String>();
		Stack<String> b=new Stack<String>();
		String cur="http://www.acm.org/";
		
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line=null;
		while((line=bf.readLine())!=null)
		{
			if(line.equals("QUIT"))break;
			if(line.indexOf("VISIT")>-1)
			{
				b.clear();
				a.push(cur);
				cur=line.split("\\s+")[1];
				System.out.println(cur);
			}else if(line.indexOf("BACK")>-1)
			{
				if(a.isEmpty())System.out.println("Ignored");
				else{
					b.push(cur);
					cur=a.pop();
					System.out.println(cur);
				}
			}else if(line.indexOf("FORWARD")>-1)
			{
				if(b.isEmpty())System.out.println("Ignored");
				else{
					a.push(cur);
					cur=b.pop();
					System.out.println(cur);
				}
			}
		}
	}

}
